﻿
@{
    Layout = "/Views/Shared/_Layout.cshtml";
    var newsid = 0;
}
@using NewsPublish.Model.Response;


<div class="content-wrap">
    <div class="content">
        @*新闻基础信息*@

        @{
            var response = ViewData["News"] as ResponseModel;
            if (response.code == 200)
            {
                newsid = response.data.Id;

                <header class="article-header">
                    <h1 class="article-title"><a href="#" title="@response.data.Title">@response.data.Title</a></h1>
                    <div class="article-meta">
                        <span class="item article-meta-time">
                            <time class="time" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="发表时间：@response.data.PublishDate">
                                <i class="glyphicon glyphicon-time"></i> @response.data.PublishDate
                            </time>
                        </span>
                        <span class="item article-meta-category" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@response.data.ClassifyName">
                            <i class="glyphicon glyphicon-list"></i>
                            <a href="/News/Classify?classifyid=@response.data.ClassifyId" title="@response.data.ClassifyName">@response.data.ClassifyName</a>
                        </span>
                        <span class="item article-meta-comment" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="评论量">
                            <i class="glyphicon glyphicon-comment"></i> @response.data.ConmmentCount
                        </span>
                    </div>
                </header>

                @*新闻内容*@
                <article class="article-content">
                    <p><img data-original="@response.data.Image" src="@response.data.Image" alt="@response.data.Title" /></p>
                    <p>
                        @response.data.Contents
                    </p>

                    <div class="bdsharebuttonbox">
                        <a href="#" class="bds_more" data-cmd="more"></a>
                        <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
                        <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
                        <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
                        <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
                        <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
                        <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
                    </div>
                </article>
            }
        }


        @*相关推荐*@
        <div class="relates">
            <div class="title">
                <h3>相关推荐</h3>
            </div>
            @{
                var recommends = ViewData["RecommendNews"] as ResponseModel;
                <ul>
                    @if (recommends.code == 200)
                    {
                        foreach (var recommend in recommends.data)
                        {
                            <li><a href="/News/Detail?newsid=@recommend.Id" title="@recommend.Title">@recommend.Title</a></li>
                        }
                    }
                </ul>
            }
        </div>

        @*评论*@
        <div class="title" id="comment">
            <h3>评论</h3>
        </div>

        @*评论填写*@
        <div id="respond">
            <form id="comment-form" name="comment-form" action="" method="POST">
                <div class="comment">
                    <div class="comment-box">
                        <textarea placeholder="您的评论或留言（必填）" name="comment-textarea" id="comment-textarea" cols="100%" rows="3" tabindex="3"></textarea>
                        <div class="comment-ctrl">
                            <div class="comment-prompt" style="display: none;"> <i class="fa fa-spin fa-circle-o-notch"></i> <span class="comment-prompt-text">评论正在提交中...请稍后</span> </div>
                            <div class="comment-success" style="display: none;"> <i class="fa fa-check"></i> <span class="comment-prompt-text">评论提交成功...</span> </div>
                            <button type="button" onclick="addComment()" name="comment-submit" id="comment-submit" tabindex="4">评论</button>
                        </div>
                    </div>
                </div>
            </form>

        </div>

        @*评论信息*@
        <div id="postcomments">
            <ol id="comment_list" class="commentlist">
                @{
                    var comments = ViewData["Comments"] as ResponseModel;
                    if (comments.code == 200)
                    {
                        @foreach (var comment in comments.data)
                        {
                            <li class="comment-content">
                                <span class="comment-f">@comment.Floor</span>
                                <div class="comment-main">
                                    <p>
                                        <a class="address" rel="nofollow" target="_blank">匿名</a>
                                        <span class="time">(@comment.AddTime)</span>
                                        <br>@comment.Contents
                                    </p>
                                </div>
                            </li>

                        }
                    }
                }
        </div>
    </div>
</div>
<aside class="sidebar">
    <div class="fixed">
        <div class="widget widget-tabs">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#notice" aria-controls="notice" role="tab" data-toggle="tab" draggable="false">统计信息</a></li>
                <li role="presentation"><a href="#contact" aria-controls="contact" role="tab" data-toggle="tab" draggable="false">联系站长</a></li>
            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane contact active" id="notice">
                    <h2>
                        新闻总数:
                        <text id="newsCount"></text>篇
                    </h2>
                    <h2>
                        网站运行:
                        <span id="sitetime">5年以上 </span>
                    </h2>
                </div>
                <div role="tabpanel" class="tab-pane contact" id="contact">
                    <h2>
                        QQ:
                        <a href="" target="_blank" rel="nofollow" data-toggle="tooltip" data-placement="bottom" title="" draggable="false" data-original-title="QQ:2835806641">2835806641</a>
                    </h2>
                    <h2>
                        Email:
                        <a href="mailto:2835806641@qq.com" target="_blank" data-toggle="tooltip" rel="nofollow" data-placement="bottom" title="" draggable="false" data-original-title="Email:2835806641@qq.com">577211782@qq.com</a>
                    </h2>
                </div>
            </div>
        </div>

    </div>
    <div class="widget widget_hot">

    </div>
    <div class="widget widget_sentence">
        <a href="http://study.163.com/instructor/1025318795.htm" target="_blank" rel="nofollow">
            <img style="width: 100%" src="/images//201610241224221511.jpg">
        </a>
    </div>
    <div class="widget widget_sentence">
        <a href="http://study.163.com/instructor/1025318795.htm" target="_blank" rel="nofollow">
            <img style="width: 100%" src="/images/ad.jpg">
        </a>
    </div>
</aside>


<script>
    window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": "1", "bdSize": "32" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=0.js?cdnversion=' + ~(-new Date() / 36e5)];
    $(function () {
        getNewsCount();
    });

    //添加新闻评论
    function addComment() {
        var content = $.trim($("#comment-textarea").val());//评论内容
        if (content != "" && content != null) {
            $.ajax({
                type: "post",
                url: "/News/AddComment",
                data: { NewsId:@newsid, Contents: content },
                success: function (result) {
                    if (result.code==200) {
                        //清空评论输入框
                        $("#comment-textarea").val("");
                        //将新加的评论信息加载到页面
                        var commentHtml = "<li class=\'comment-content\'><span class=\'comment-f\'>" + result.data.floor + "</span><div class=\'comment-main\'><p><a class=\'address\'  rel=\'nofollow\' target=\'_blank\'>匿名</a><span class=\'time\'>(" + result.data.addTime + ")</span><br>" + result.data.contents + "</p></div></li>";
                        $("#comment_list").prepend(commentHtml);
                    } else {
                        alert(result.result);
                    }
                }
            });
        } else {
            alert("请输入评论后提交");
        }
    }

    //获取新闻总数
    function getNewsCount() {
        $.ajax({
            type: "get",
            url: "/Home/GetNewsCount",
            success: function (result) {
                if (result.code == 200) {
                    $("#newsCount").text(result.data);
                }
            }
        });
    }

</script>
